#include "elpalette.h"

ElPalette::ElPalette() {}

ElPalette &ElPalette::toggleColorGroup(ColorGroup colorGroup)
{
    if (_currentColorGroup == colorGroup)
        return *this;
    _currentColorGroup = colorGroup;
    return *this;
}

ElPalette::ColorGroup ElPalette::currentColorGroup() const
{
    return _currentColorGroup;
}

ElPalette &ElPalette::setColor(ColorGroup colorGroup, ColorRole colorRole, const QColor &color)
{
    auto pair = std::make_pair(colorGroup, colorRole);
    _colors[pair] = color;
    return *this;
}

QColor ElPalette::color(ColorGroup colorGroup, ColorRole colorRole) const
{
    auto pair = std::make_pair(colorGroup, colorRole);
    if (_colors.find(pair) == _colors.end())
        return Qt::white;
    return _colors[pair];
}
